// useBuiltIns 和 transform-runtime不可混用
// https://github.com/babel/babel/issues/10008

module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
        useBuiltIns: 'usage', // 只注入不兼容ecma语法功能的polyfills
        corejs: {
          version: 3,
          proposals: true
        }
      }
    ]
    // ['@vue/cli-plugin-babel/preset']
  ],
  plugins: [
    [
      '@babel/plugin-transform-modules-commonjs',
      {
        allowTopLevelThis: true
      }
    ],
    '@babel/plugin-transform-runtime',
    ['@babel/plugin-proposal-class-properties', { loose: true }],
    // 转换jsx语法
    '@babel/plugin-syntax-jsx',
    // 转换vue jsx
    'transform-vue-jsx',
    // element-ui按需加载配置
    [
      'component',
      {
        libraryName: 'element-ui',
        styleLibraryName: 'theme-chalk'
      }
    ]
  ]
}
